<template>
  <div @click="sendSkipToNote" class="mw-column-center-style" style="position:relative;width:1.72rem;margin-top: 0.1rem;border-radius: 0.04rem;">
    <img style="width:1.72rem;border-radius: 0.04rem 0.04rem 0 0;" :src="item.cover_url"></img>
    <div class="mw-column-center-style mw-main-background-white" style="padding:0.1rem;border-radius: 0 0 0.04rem 0.04rem">
      <div class="mw-n-line" style="font-size: 0.13rem;line-height: 0.18rem;width: 1.52rem;height:0.36rem;margin-bottom: 0.08rem">{{item.title}}</div>
      <div class="mw-row-spacebetween-style mw-third-text-color" style="width:1.52rem;align-items: center;font-size: 0.11rem;">
        <div @click.stop="sendSkipToUserPage" v-if="item.hasOwnProperty('user')" class="mw-row-style" style="align-items: center">
          <img class="mw-avatar-style" style="width: 0.2rem;height:0.2rem;border-radius: 0.1rem;"  :src="item.user.avatar == ''? '/static/defalut_avatar.png':item.user.avatar"></img>
          <div class="mw-single-line" style="margin-left:0.04rem;width:0.77rem;">{{item.user.name}}</div>
        </div>
        <div class="mw-row-style" style="align-items: center">
          <img @click.stop="clickLike" style="height:0.16rem;width:0.16rem;object-fit:cover;margin-right:0.03rem" :src="item.liked == 1 ? '/static/article_zan.png':'/static/zan_show.png'" />
          <div>{{item.liked_total < 10000 ? item.liked_total : (Math.floor(item.liked_total / 10000 * 10) / 10 + 'w')}}</div>
        </div>
      </div>
    </div>
    <img v-if="item.is_video == 1" style="position: absolute;top:0.08rem;right:0.08rem;height:0.2rem;width: 0.2rem;object-fit: cover" src="/static/note_video_block_icon.png"></img>
  </div>

</template>
<script>
  import utils from '../utils'
  import httputil from '../httputil'
  export default {
    props: ['item','enter'],
    data() {
      return {

      }
    },
    computed: {},
    methods: {
      sendSkipToNote(){
        this.$vuet.getModule(this.enter).needFetch = false
        this.$router.push({name: 'notedetail', query: {id: this.item.id}})
//        this.$emit('receiveSkipToNote',this.item.id)
      },
      sendSkipToUserPage(){
        this.$vuet.getModule(this.enter).needFetch = false
        this.$router.push({name: 'userpage', query: {id: this.item.user.id}})
      },
      clickLike(){
        var that = this
        if (this.$getLoginStatus()) {
          if (this.item.liked == 0) {
            this.item.liked = 1
            this.item.liked_total = this.item.liked_total + 1
          } else {
            this.item.liked = 0
            this.item.liked_total = this.item.liked_total - 1
          }
        }
        var params = {id: this.item.id}
        httputil.request("like/note", params, function (successresult) {
          that.item.liked = successresult.liked
        }, function (errorresult) {

        }, "POST", false, that.enter)
      },

    }
  }

</script>
<style scoped>

</style>
